<< back

Embedded Programming

Two weeks ago in the Electronics Design week I made the basic board with 1 LED and 1 Button. This week my task is to program the board so that the LED would light up when the button is pressed.

I'm using Windows and it did take me some time to gather all the information and instructions needed.

I began by following the ladyada's tutorial which I found very helpful. The first thing is to download WinAVR and install. Then prepare the programmer. Since my FabISP isn't working properly probably due to poor soldering, I worked with the AVRISP V2 programmer this time.

Before you program the board, if you are Windows user you actually have to download (LINK) and install the driver for the AVRISP V2 first. I installed the driver with the Device Manager in Windows.

After that I downloaded the files "hello.ftdi.44.echo.c" & "hello.ftdi.44.echo.c.make" from the class website, and then used these commands (change usbtiny to avrisp2) in the command window to program the board.

The program was uplaoded to the board. To test if it is working properly, I used a serial terminal program called "RealTerm" (LINK). Remember to locate the correct Port and change the Baud to 115200.

After knowing that the board and the program was working fine, I was a bit confused about what to do next. Fortunately I got the great help from Dan to figure that out. I modified the code from Shahar Ronen and created a new .c file "blink.c", then changed my Make file so that it is pointing to this "blink.c" instead of "hello.ftdi.44.echo.c". After that I used the below command lines again to compile and upload the program to the board.

make -f hello.ftdl.44.echo.c.make

make -f hello.ftdl.44.echo.c.make program-avrisp2

Then a strange situation happened. The LED just kept blinking no matter I pressed the button or not. After some debugging processes with Palash's great help, we figured out that the input pin of my microcontroller that is connected to the switch is receiving Low signal no matter the button is pressed or not. After checking with the multimeter, I found that it is probably the switch itself that caused the problem. I therefore desoldered the switch and replaced that with a new one. Then it works!!

A big thanks to Palash, Dan Chen, Alexis Hope, Saquib, and Dan Novy who offered great help for my programming and debugging!!